package com.chenfan.mcn.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfan.common.extension.mybatisplus.enhanced.EnhancedBaseMapper;
import com.chenfan.mcn.model.DiscountApproval;
import com.chenfan.mcn.model.McnPage;
import com.chenfan.mcn.model.dto.ApprovalSearchDTO;
import com.chenfan.mcn.model.dto.DiscountDTO;
import com.chenfan.mcn.model.dto.DiscountApprovalSearchDTO;
import com.chenfan.mcn.model.vo.ContractVerifyVO;
import com.chenfan.mcn.model.vo.DiscountApprovalRelationVO;
import com.chenfan.mcn.model.vo.DiscountApprovalVO;
import com.chenfan.mcn.model.vo.DiscountInfoVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 折扣审批单 Mapper 接口
 * </p>
 *
 * @author lizhejin
 * @since 2021-01-07
 */
public interface DiscountApprovalMapper extends EnhancedBaseMapper<DiscountApproval> {

    /**
     * 分页数据
     *
     * @param page 分页信息
     * @param dto  过滤条件
     * @return
     */
    Page<DiscountApprovalVO> selectTableList(McnPage<DiscountApprovalVO> page, @Param("dto") DiscountApprovalSearchDTO dto);

    /**
     * 获取折扣审批单详情
     *
     * @param id 折扣审批单id
     * @return {@link DiscountDTO}
     */
    DiscountInfoVO selectDiscountApproval(@Param("id") Long id);

    /**
     * 重复时间端的数量
     *
     * @param dto 过滤条件
     * @return int
     */
    int selectActiveCounts(@Param("dto") DiscountDTO dto);

    /**
     * 校验合同
     *
     * @param dto
     * @return ContractVerifyVO
     */
    ContractVerifyVO verifyContract(@Param("dto") ApprovalSearchDTO dto);

    /**
     * 获取单笔折扣审批
     *
     * @param dto
     * @return List<ContractVerifyVO>
     */
    List<Long> getDiscountIdList(@Param("dto") ApprovalSearchDTO dto);

    /**
     * 根据客户Id获取折扣审批单
     *
     * @param customerId 客户id
     * @param selected 是否下拉框
     * @return {@link DiscountApproval}
     */
    List<DiscountApprovalVO> selectByCustomerId(Long customerId, boolean selected);

    /**
     * 根据客户名称获取折扣返点审批单号(所有类型是【年度优惠】的折扣返点审批单，且状态是审核通过。)
     *
     * @param customerId {@link Long}
     * @return {@link List}
     */
    List<String> getDisCountApprovalCode(Long customerId);

    /**
     * 根据折扣审批单编号获取
     *
     * @param discountCode {@link String}
     * @return {@link DiscountApproval}
     */
    DiscountApproval selectByDiscountCode(String discountCode);

    /**
     * 客户档案关联折扣审批单
     *
     * @param page
     * @param customerId
     * @return
     */
    Page<DiscountApprovalRelationVO> getDiscountApprovalRelationList(McnPage<DiscountApprovalRelationVO> page, @Param("customerId") Long customerId);
}
